import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)
const layout=()=>import('../views/layout.vue')
const home=()=>import('../views/Home.vue')
const err =()=>import('../views/err.vue')
const my =()=>import('../views/My.vue')
const cart =()=>import('../views/Cart.vue')
const menu =()=>import('../views/Menu.vue')
const routes = [
  {
    path: '/',
    component: layout,
    children:[
      {
        path:'',//默认子路由
        component:home
      },
      {
        path:'my',//
        component:my
      },
      {
        path:'menu',//默认子路由
        component:menu
      },
      {
        path:'cart',//默认子路由
        component:cart
      }
    ]
  },
  {
    path:'*',
    component:err
  }
]

const router = new VueRouter({
  mode:'history',
  routes
})

export default router
